/*******************************************************************
 * 外语翻译平台(translate) 
 *
 * 成都一亿信息技术公司 版权所有
 * 
 * Copyright (C) 2010 Transer Information Technology Co., Ltd.
 *
 * @Version : 1.0  2010-12-26 下午07:51:37
 *
 * QueryProfileLanguageJob.java 
 *
 *******************************************************************/
package com.transer.job;

import java.util.List;

import org.apache.log4j.Logger;

import com.transer.persistance.bean.ProfileLanguage;
import com.transer.persistance.bean.User;
import com.transer.persistance.dao.DatabaseDao;
import com.transer.persistance.dao.IUserDao;

/**
 * class defination are there
 * 
 * @author Mark
 * 
 * @version 1.0 ywengineer@gmail.com
 * 
 */
public class QueryProfileLanguageJob implements Runnable {
	// 收件人
	private User user;
	// 数据库操作
	private DatabaseDao database;

	public QueryProfileLanguageJob(DatabaseDao dao, User user) {
		this.database = dao;
		this.user = user;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Runnable#run()
	 */
	public void run() {
		try {
			// 如果数据库操作为空,返回
			if (database == null || user == null) {
				return;
			}
			// 用户操作
			IUserDao userDao = (IUserDao) database;
			// 查询用户语言配对
			List<ProfileLanguage> profiles = userDao.getProfileLanguages(user.getId());
			// 设置该用户配对信息
			user.setLanguagePairs(profiles);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("设置用户语言配对信息失败", e);
		} finally {
			database = null;
		}
	}

	private static final Logger logger = Logger.getLogger(QueryProfileLanguageJob.class);
}
